//
//  DSSHMeWalletVC.m
//  DSSH
//
//  Created by lcy on 16/3/29.
//  Copyright © 2016年 lcy. All rights reserved.
//

#import "DSSHMeWalletVC.h"
#import "UIView+Round.h"

@interface DSSHMeWalletVC ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView * walletTableView;
@end

@implementation DSSHMeWalletVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupViewAndData];
    // Do any additional setup after loading the view.
}
-(void)setupViewAndData
{
    self.title = @"我的钱包";
    UIBarButtonItem * backBarBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"fanhui"] style:UIBarButtonItemStylePlain target:self action:@selector(backBarBtnClick)];
    self.navigationItem.leftBarButtonItem = backBarBtn;
    self.view.backgroundColor = [UIColor whiteColor];
    self.walletTableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    self.walletTableView.delegate = self;
    self.walletTableView.dataSource = self;
    self.walletTableView.tableFooterView = [[UIView alloc]init];
    [self.view addSubview:self.walletTableView];
}
-(void)backBarBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * cellID = @"cellID";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
    }
    if (indexPath.section == 0)
    {
        cell.contentView.backgroundColor = COLOR_NAVIGATE_BAR;
        UIView * bgView = [UIView new];
        bgView.frame = CGRectMake(5*WIDTH_SCALE, 5*HIGHT_SCALE,ZYAppWidth-5*2*WIDTH_SCALE, 90*HIGHT_SCALE);
        [bgView getRoundView:4];
        bgView.backgroundColor = [UIColor whiteColor];
        [cell.contentView addSubview:bgView];
        
        UILabel * titleLabel = [UILabel new];
        titleLabel.text = @"当前余额";
        titleLabel.frame = CGRectMake(10*WIDTH_SCALE, 10*WIDTH_SCALE, 100*WIDTH_SCALE, 20*HIGHT_SCALE);
        titleLabel.textColor = [UIColor grayColor];
        titleLabel.font = FONT(13);
        [bgView addSubview:titleLabel];
        
        UILabel * moneyLabel = [UILabel new];
        moneyLabel.text = @"0.00";
        moneyLabel.font = FONT(22);
        moneyLabel.textColor = [UIColor orangeColor];
        [bgView addSubview:moneyLabel];
        
        CGRect labelMoneySize = [moneyLabel.text boundingRectWithSize:CGSizeMake(ZYAppWidth, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:FONT(22)} context:nil];
        
        UILabel * yuanLabel = [UILabel new];
        yuanLabel.text = @"元";
        yuanLabel.font = FONT(14);
        yuanLabel.textColor = [UIColor orangeColor];
        [bgView addSubview:yuanLabel];
        
        UIButton * submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [submitBtn setTitle:@"申请提现" forState:UIControlStateNormal];
        [submitBtn setBackgroundColor:RGBA(242, 85, 56, 1)];
        [submitBtn addTarget:self action:@selector(clickSubmitBtn) forControlEvents:UIControlEventTouchUpInside];
        [submitBtn getRoundView:5];
        [bgView addSubview:submitBtn];
        
        [moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell.contentView.mas_left).with.offset(15*WIDTH_SCALE);
            make.centerY.mas_equalTo(cell.contentView.mas_centerY);
            make.height.mas_equalTo(labelMoneySize.size.height);
            make.width.mas_equalTo(labelMoneySize.size.width+5*WIDTH_SCALE);
        }];
        [yuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(moneyLabel.mas_right).with.offset(0);
            make.bottom.mas_equalTo(moneyLabel.mas_bottom);
//            make.height.mas_equalTo(20*HIGHT_SCALE);
            make.width.mas_equalTo(20*WIDTH_SCALE);
        }];
        [submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bgView.mas_right).with.offset(-25*WIDTH_SCALE);
            make.bottom.mas_equalTo(moneyLabel.mas_bottom);
            make.height.mas_equalTo(40*HIGHT_SCALE);
            make.width.mas_equalTo(150*WIDTH_SCALE);
        }];

        
    }else
    {
        cell.textLabel.text = @"支付设置";
        cell.imageView.image = [UIImage imageNamed:@"iconfont_icon5"];
        [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    }
    return cell;
}
#pragma 申请提现
-(void)clickSubmitBtn
{
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.00001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        return 100*HIGHT_SCALE;
    }else
    {
        return 44*HIGHT_SCALE;
    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
